package com.tang.segment.segmentcontrol;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
               SegmentControl segmentControl = findViewById(R.id.segment);

        segmentControl.setOnSegmentChangedListener(new SegmentControl.OnSegmentChangedListener() {
            @Override
            public void onSegmentChanged(int newSelectedIndex) {
                Toast.makeText(getApplicationContext(),"选择"+newSelectedIndex,Toast.LENGTH_SHORT).show();
            }
        });



    }
}
